void doTCPClientTick() {
  if(WiFi.status() != WL_CONNECTED) return;
  if (!TCPclient.connected()) {
    #ifdef ESP32
    TCPclient.stop();
    #else
    TCPclient.stopAll();
    #endif
    if (preTCPConnected == true) {
      preTCPConnected = false;
      preTCPStartTick = millis();
      Serial.println();
      Serial.println("TCP Client disconnected.");
    } else if (millis() - preTCPStartTick > 1*1000) {
      startTCPClient();
    }
  } else {
    if (TCPclient.available()) {
      char c =TCPclient.read();
      TcpClient_Buff +=c;
      TcpClient_BuffIndex++;
      TcpClient_preTick = millis();
      if (TcpClient_BuffIndex >= MAX_PACKETSIZE - 1) {
        TcpClient_BuffIndex = MAX_PACKETSIZE-2;
        TcpClient_preTick = TcpClient_preTick - 200;
      }
    }
    if (millis() - preHeartTick >= KEEPALIVEATIME) {
      preHeartTick = millis();
      Serial.println("--Keep alive:");
      sendtoTCPServer("ping\r\n");
    }
  }
  if ((TcpClient_Buff.length() >= 1) && (millis() - TcpClient_preTick>=200)) {
    TCPclient.flush();
    TcpClient_Buff.trim();
    String topic = "";
    String msg = "";
    if (TcpClient_Buff.length() > 15) {
      int topicIndex = TcpClient_Buff.indexOf("&topic=")+7;
      int msgIndex = TcpClient_Buff.indexOf("&msg=");
      topic = TcpClient_Buff.substring(topicIndex,msgIndex);
      msg = TcpClient_Buff.substring(msgIndex+5);
    }
    {{&funcBranch}}
    msg = "";
    topic = "";
    TcpClient_Buff="";
    TcpClient_BuffIndex = 0;
  }
}